Just some additional comments.

You need to make sure your code is neatly formatted and indented; something like this:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
int main()
{
    FILE *ofp;
    int k=0, i=1000000;;
    int array[i];

    ofp=fopen("output.txt","w");
    
    while (ofp==NULL)
    {
        printf("File is corrupted or does not exist, please solve the problem and press enter to proceed");
        getchar();
    }
 
    srand(time(NULL));
    rand();
 
    for (k=0;  k<1000000; k++)
    {
        array[k] = rand()%100;
        fprintf(ofp, "%d\n", array[k]);
    }

    return 0;
}
That first "while()" should be an "if()". Otherwise, if the file fails to open (and "ofp" is NULL), you'll be in an infinite loop. Also, you should exit the program if the file fails to open.

That "rand()" call immediately after "srand()" isn't doing anything; you don't need it.